Report with pictures

The "Picture" object, as well as many objects in FastReport, can display data from DB. The connection of an object to a required DB field is realized with the help of the "DataSet" and "DataField" properties in the object inspector. In contrast to the "Text" object, this is the only way to connect an object to data.

Let us demonstrate the aforesaid with a report, which would have images of fishes, and their names. To perform this, we will again need the "DBDEMOS" demonstration database, which is included in Delphi distribution kit.

Let us create a blank project in Delphi, and then put the "TTable" component on the form and set its properties:

DatabaseName = 'DBDEMOS'
TableName = 'Biolife.db'

For working with a table from FastReport, let us add the "TfrxDBDataSet" component and set its properties:

DataSet = Table1
UserName = 'Bio'

Finally, let us put the "TfrxReport" component on the form. Open the designer and click the "New report" button, so that FastReport would create a blank pattern. Let us connect a table to the report in the"Report|Data..." window.

Let us begin creating a report form. Put the "Text" object with the "Fish" text on the "ReportTitle" band. Connect the "First level data" band to the data source (doubleclick on the band and select "Bio" from the list). Let us increase the band height up to 3 cm so that the picture finds room in it. Let us put the "Text" object to the band and connect it to the"CommonName" field using any of the methods described above. After that, drop the "Picture" object alongside, and connect it to the "Graphic" field. To perform this, set properties in the object inspector:

DataSet = Bio
DataField = 'Graphic'

Note, that both of these properties are of the "List" type, and that is why one can select the required values with the help of the mouse. To find room for the picture, stretch the object up to 4x2.5cm.

That is all. The report is finished (see the picture below):